/* ppptiqa.p - ITEM-SITE INQUIRY SUBROUTINE                             */
/* Copyright 1986-2011 QAD Inc., Santa Barbara, CA, USA.                      */
/* All rights reserved worldwide.  This is an unpublished work.         */
/* $Id:: ppptiqa.p 7260 2011-05-06 21:02:42Z zzh                           $: */
/* REVISION: 7.0      LAST MODIFIED: 03/11/92   BY: WUG *F281*          */
/* REVISION: 7.0      LAST MODIFIED: 05/30/92   BY: pma *F561*          */
/* REVISION: 7.0      LAST MODIFIED: 06/18/92   BY: emb *F687*          */
/* REVISION: 7.0      LAST MODIFIED: 07/20/92   BY: pma *F782*          */
/* REVISION: 7.0      LAST MODIFIED: 08/17/92   BY: pma *F855*          */
/* REVISION: 7.0      LAST MODIFIED: 10/29/92   BY: pma *G249*          */
/* REVISION: 7.0      LAST MODIFIED: 11/09/92   BY: pma *G299*          */
/* Revision: 7.3      Last edit:     11/19/92   by: jcd *G339*          */
/* REVISION: 7.3      LAST MODIFIED: 02/15/93   BY: pma *G680*          */
/* REVISION: 7.3      LAST MODIFIED: 02/15/93   BY: pma *G032*          */
/* REVISION: 7.4      LAST MODIFIED: 08/25/93   BY: dpm *H075*          */
/*           7.4                     09/03/94   BY: bcm *GL93*          */
/* REVISION: 7.4      LAST MODIFIED: 09/20/94   BY: ais *FR64*          */
/* REVISION: 7.4      LAST MODIFIED: 11/06/94   BY: ljm *GO15*          */
/* REVISION: 7.4      LAST MODIFIED: 03/02/95   BY: qzl *F0L7*          */
/* REVISION: 7.4      LAST MODIFIED: 03/30/95   BY: aed *G0J8*          */
/* REVISION: 7.4      LAST MODIFIED: 04/03/95   BY: aed *G0FB*          */
/*           7.4      LAST MODIFIED: 07/13/95   BY: jzs *G0S6*          */
/* REVISION: 8.5      LAST MODIFIED: 06/06/96   BY: ruw *J0QW*          */
/* REVISION: 8.5      LAST MODIFIED; 08/27/96   BY: *G2B6* Julie Milligan */
/* REVISION: 8.6      LAST MODIFIED: 10/11/96   BY: flm *K003*            */
/* REVISION: 8.6      LAST MODIFIED: 12/05/96   BY: *G2HJ* Murli Shastri  */
/* REVISION: 8.6      LAST MODIFIED: 06/09/97   BY: *K0D8* Arul Victoria */
/* REVISION: 8.6      LAST MODIFIED: 06/24/97   BY: *K0DH* Arul Victoria */
/* REVISION: 8.6      LAST MODIFIED: 07/30/97   BY: Joe Gawel    *K0H6* */
/* REVISION: 8.6      LAST MODIFIED: 10/09/97   BY: mzv *K0PK* */
/* REVISION: 8.6      LAST MODIFIED: 11/29/97   BY: *G2QD* Manmohan Pardesi */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane        */
/* REVISION: 8.6E     LAST MODIFIED: 05/05/98   BY: *H1L1* Samir Bavkar     */
/* REVISION: 8.6E     LAST MODIFIED: 05/15/98   BY: *J2LM* Suresh Nayak     */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan       */
/* REVISION: 8.6E     LAST MODIFIED: 10/28/98   BY: *J330* Mugdha Tambe     */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00 BY: *N08T* Annasaheb Rahane   */
/* REVISION: 9.1      LAST MODIFIED: 05/12/00   BY: *N09X* Antony Babu      */
/* REVISION: 9.1      LAST MODIFIED: 08/13/00   BY: *N0KQ* myb              */
/* Old ECO marker removed, but no ECO header exists *F0PN*                    */
/* Revision: 1.18.1.4    BY: Russ Witt          DATE: 09/21/01 ECO: *P01H*    */
/* Revision: 1.18.1.5    BY: Zheng Huang        DATE: 01/31/02 ECO: *P000*    */
/* Revision: 1.18.1.7    BY: Paul Donnelly (SB) DATE: 06/28/03 ECO: *Q00K*    */
/* Revision: 1.18.1.8    BY: Vandna Rohira      DATE: 02/14/05 ECO: *P35T*    */
/* Revision: 1.18.1.9    BY: Shilpa Kamath      DATE: 04/04/06 ECO: *R03R*    */
/* Revision: 1.18.1.11   BY: Niranjan Ranka     DATE: 06/05/06 ECO: *R05V*    */
/* Revision: 1.18.1.12   BY: Niranjan Ranka     DATE: 07/05/06 ECO: *R073*    */
/* Revision: 1.18.1.13   BY Hitendra PV         DATE: 08/23/06 ECO: *R05T* */
/* Revision: 1.18.1.14   BY Russ Witt           DATE: 10/20/06 ECO: *R08M* */
/* Revision: 1.18.1.15   BY: Dipanshu Talwar    DATE: 01/19/09 ECO: *Q28F* */
/* Revision: 1.18.1.17  BY: Zhijun Guan       DATE: 11/09/09 ECO: *R1V9* */
/* $Revision: 1.18.1.18 $ BY: Steve Nugent     DATE: 07/15/10 ECO: *Q2W2* */
/*-Revision end---------------------------------------------------------------*/

/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

/*  CHANGES DONE IN THIS PROGRAM ALSO NEEDS TO BE DONE IN ppptiqb.p */

{us/mf/mfdtitle.i "3+ "}
{us/px/pxmaint.i}
{us/px/pxphdef.i pprevxr}
{us/px/pxphdef.i gplngxr}
{us/px/pxphdef.i ppitxr}

define shared variable ppform as character.

define new shared variable in_recno as recid.
define new shared variable si_recno as recid.
define variable frtitle as character format "x(24)".
define new shared variable csset as character.

define new shared frame c0.
define new shared frame d.
define new shared frame d0.
define new shared frame d1. /*used by ppptiqa.p*/

define variable itemIssuePolicy     like pti_iss_pol no-undo.
define variable issuePolicyDisp     as character format "x(8)" no-undo.
define variable issuePolicyDispDesc as character format "x(24)"
   no-undo.
define variable itemPickPolicy     like pti_pick_pol no-undo.
define variable pickPolicyDisp     as character format "x(8)" no-undo.
define variable pickPolicyDispDesc as character format "x(24)"
   no-undo.
define variable pickingOrder     as character format "x(24)".
define variable pickingAscDesc   as character format "x(24)".
define variable ptPickOrder      like pt_pk_ord no-undo.
define variable ptPickAscend     like pt_ascend no-undo.
define variable itemABC          like pt_abc no-undo.

define variable s_mtl like sct_mtl_tl.
define variable s_lbr like sct_lbr_tl.
define variable s_bdn like sct_bdn_tl.
define variable s_ovh like sct_ovh_tl.
define variable s_sub like sct_sub_tl.
define variable site like si_site.

define variable yn like mfc_logical.
define variable cfg like pt_cfg_type format "x(3)" no-undo.
define variable cfglabel as character format "x(24)" label ""
   no-undo.
define variable cfgcode as character format "x(1)" no-undo.

define new shared variable global_costsim like sc_sim.
define new shared variable global_category like sc_category.
define new shared workfile sptwkfl
   field element  like spt_element column-label "Element"
   field primary  like mfc_logical column-label "Pri"
   field prim2    like mfc_logical
   field ao       like spt_ao      column-label "A/O"
   field cst_tl   like spt_cst_tl  column-label "This Level"
   field cst_ll   like spt_cst_ll  column-label "Lower Level"
   field cst_tot  like spt_cst_tl  column-label "Total"
   field cat_desc as character     column-label "Category"
   field seq      like spt_pct_ll
   field part     like pt_part.

define variable btb-type       like pt_btb_type
   format "x(8)" no-undo.
define variable btb-type-desc  like glt_desc     no-undo.
define variable atp-enforcement      like pt_atp_enforcement
   format "x(8)"   no-undo.
define variable atp-enforce-desc like glt_desc     no-undo.
define variable emt-auto as logical label "Auto EMT Processing"
   no-undo.
define variable l_comm_code like comd_comm_code no-undo.
define variable c_fiscal_desc as character format "x(40)" no-undo.
define variable gl_site     like in_gl_cost_site  label "GL Site" no-undo.
define variable ptRev  like ptrv_rev no-undo.
define variable ptpRev like ptrv_rev no-undo.
define variable replenishment_method as character
   format "x(10)" label "Replenishment Method" no-undo.
define variable replenishment_method_label as character no-undo.
define variable validmnemonic as logical no-undo.
define variable schedType     like pt_schedule_type no-undo.
define variable smoothingRule like pt_smoothing_rule no-undo.
define variable periodType    like pt_period_type no-undo.
define variable cdesc         as character no-undo.
define variable ptavgperiod   like pt_avg_period no-undo.
/* Printable version of frame a */
form
   pt_part        colon 14
   pt_desc1       at    36 no-label
   site           colon 14 label "Inv Site"
   pt_um          colon 30 label "UM"
   pt_desc2       at    36 no-label
with frame a0 side-labels width 80.

/* SET EXTERNAL LABELS */
setFrameLabels(frame a0:handle).

form
   pt_part        colon 14
   pt_desc1       at    36 no-label
   site           colon 14 label "Inv Site"
   pt_um          colon 30 label "UM"
   pt_desc2       at    36 no-label
with frame a side-labels width 80 attr-space.

/* SET EXTERNAL LABELS */
setFrameLabels(frame a:handle).

form
   {us/pp/ppptmta2.i}

with frame a1 title color normal (getFrameTitle("ITEM_DATA",20))
   side-labels width 80.

/* SET EXTERNAL LABELS */
setFrameLabels(frame a1:handle).

form
   {us/pp/pppsmta3.i}
with frame b1 title color normal
   (getFrameTitle("ITEM_INVENTORY_DATA",28))
   side-labels width 80 .

/* SET EXTERNAL LABELS */
setFrameLabels(frame b1:handle).

form
   {us/pp/pppsmta4.i}
with frame c1 title color normal
   (getFrameTitle("ITEM_PLANNING_DATA",26))
   side-labels width 80.

/* SET EXTERNAL LABELS */
setFrameLabels(frame c1:handle).

form
   {us/pp/ppptmta4.i}
with frame c title color normal
   (getFrameTitle("ITEM_PLANNING_DATA",26))
   side-labels width 80 .

/* SET EXTERNAL LABELS */
setFrameLabels(frame c:handle).

form {us/pp/ppptmtab.i}
with frame c0 title color normal (getFrameTitle("SMOOTHING_RULES_DATA",26))
   side-labels width 80 .

/* SET EXTERNAL LABELS */
setFrameLabels(frame c0:handle).

form
   {us/pp/pppsmta5.i}
with frame c2 title color normal
   (getFrameTitle("PURCHASE_ORDER_DATA",26))
   side-labels width 80 .

/* SET EXTERNAL LABELS */
setFrameLabels(frame c2:handle).

form
   {us/pp/ppptmta6.i}
with frame c3 title color normal
   (getFrameTitle("PURCHASE_ORDER_DATA",26))
   side-labels width 80 .

/* SET EXTERNAL LABELS */
setFrameLabels(frame c3:handle).

form
   {us/pp/ppptmta5.i}
with frame d1 title color normal
   (getFrameTitle("ITEM_PRICE_DATA",23))
   side-labels width 80 .

/* SET EXTERNAL LABELS */
setFrameLabels(frame d1:handle).

form
   {us/pp/ppptmta9.i}
with frame d ? down title color normal frtitle
   width 80.

/* SET EXTERNAL LABELS */
setFrameLabels(frame d:handle).

/* FOR BOOLEAN VALUE IN DOWN FRAME,    */
/* ENSURE TRANSLATION TO USER LANGUAGE */
{us/gp/gpfrmdis.i &fname = "d"}

form
   {us/pp/ppptmta9.i}
with frame d0 1 down width 80 /*overlay row startrow */ no-labels
   title color normal (getFrameTitle("TOTALS",16)) .

form
   {us/pp/pppsmt10.i}
with frame bb title color normal
   (getFrameTitle("ITEM_SHIPPING_DATA",26))
   side-labels width 80 attr-space.

/* SET EXTERNAL LABELS */
setFrameLabels(frame bb:handle).

{us/wb/wbrp02.i}
mainloop:
repeat:

   hide frame a1.
   hide frame b1.
   hide frame c.
   hide frame c0.
   hide frame c1.
   hide frame c2.
   hide frame c3.
   hide frame d0.
   hide frame d.
   hide frame d1.
   hide frame bb.


   display
      global_part @ pt_part
      global_site @ site
   with frame a.

   if c-application-mode <> 'web' then
   prompt-for pt_part site
   with no-validate frame a
      editing:

      if frame-field = "pt_part" then do:
         /* FIND NEXT/PREVIOUS RECORD */

         {us/mf/mfnp.i in_mstr pt_part  " in_mstr.in_domain = global_domain and
         in_part "  site in_site in_part}

      end.
      else if frame-field = "site" then do:

         /*REPLACE ALT-NUM WHEN LEAVING pt_part FIELD*/
         {us/pp/ppalsu.i "input pt_part" pt_part:screen-value " pt_part:screen-value @ pt_part with frame a"}

         /* FIND NEXT/PREVIOUS RECORD */
         {us/mf/mfnp01.i in_mstr site in_site in_part
            " in_mstr.in_domain = global_domain and input  pt_part" in_part}
      end.
      else do:
         readkey.
         apply lastkey.
      end.
      if recno <> ? then do:
         find pt_mstr no-lock  where pt_mstr.pt_domain = global_domain and
         pt_part = in_part no-error.
         if available pt_mstr then

         display
            in_part @ pt_part
            pt_desc1
            in_site @ site
            pt_um
            pt_desc2
         with frame a.
      end.
   end.

   {us/pp/ppalsu.i "input pt_part" pt_part:screen-value " pt_part:screen-value @ pt_part with frame a"}

   {us/wb/wbrp06.i &command = prompt-for &fields =" pt_part
        site " &frm = "a"}

   if (c-application-mode <> 'web') or
      (c-application-mode = 'web' and
      (c-web-request begins 'data')) then do:

      if input pt_part = "" then do:
         {us/bbi/pxmsg.i &MSGNUM=40 &ERRORLEVEL=3}  /*BLANK NOT ALLOWED*/
         if c-application-mode = 'web' then return.
         else                undo, retry.
      end. /*INPUT BLANK*/

find pt_mstr using  pt_part where pt_mstr.pt_domain = global_domain  no-lock
no-error.
      if not available pt_mstr then do:
         {us/bbi/pxmsg.i &MSGNUM=16 &ERRORLEVEL=3}
         if c-application-mode = 'web' then return.
         else  undo, retry.
      end.

      global_part = pt_part.
      {us/px/pxgetph.i pprevxr}
      ptRev = {us/px/pxfunct.i &FUNCTION='getValidItemRevision'
         &PROGRAM='pprevxr.p'
         &HANDLE=ph_pprevxr
         &PARAM= "input pt_part,
           input '',
           input today"}.
      assign site.

      if not can-find (si_mstr  where si_mstr.si_domain = global_domain and
      si_site = site)
         and site <> ""
      then do:
         {us/bbi/pxmsg.i &MSGNUM=708 &ERRORLEVEL=3}

         if c-application-mode = 'web' then return.
         else next-prompt site with frame a.
         undo, retry.
      end.

      global_site = site.

      display
         pt_part
         pt_desc1
         site
         pt_um
         pt_desc2
      with frame a.

   end.

   /* OUTPUT DESTINATION SELECTION */
   {us/gp/gpselout.i &printType = "terminal"
      &printWidth = 80
      &pagedFlag = " "
      &stream = " "
      &appendToFile = " "
      &streamedOutputToTerminal = " "
      &withBatchOption = "no"
      &displayStatementType = 1
      &withCancelMessage = "yes"
      &pageBottomMargin = 6
      &withEmail = "yes"
      &withWinprint = "yes"
      &defineVariables = "yes"}

   for each in_mstr no-lock  where in_mstr.in_domain = global_domain and (
   in_part = pt_part
         and (in_site = site or site = "") ) :

      {us/mf/mfrpchk.i}
      yn = yes.

      if dev = "terminal"
      then
          display
            pt_part
            pt_desc1
            in_site @ site
            pt_um
            pt_desc2
          with frame a.
       
      else if  site = "" 
      then
          display  
            pt_part
            pt_desc1
            in_site @ site
            pt_um
            pt_desc2
           with frame a0.
       
     if ppform = ""
     then do:

         display {us/pp/ppptmta2.i} with frame a1.

         /*  REVISION NUMBER IS DISPLAYED FROM PTP_DET TO GET LATEST  */
         /*  MODIFIED REVISION NUMBER                                 */

         for first ptp_det
             where ptp_det.ptp_domain = global_domain and  ptp_part = pt_part
            and   ptp_site = site
         no-lock:
         end. /* FOR FIRST PTP_DET */

         if available ptp_det then
      do:
            {us/px/pxgetph.i pprevxr}
            ptpRev = {us/px/pxfunct.i &FUNCTION='getValidItemRevision'
               &PROGRAM='pprevxr.p'
               &HANDLE=ph_pprevxr
               &PARAM= "input ptp_part,
                 input ptp_site,
                 input today"}.

            display ptpRev @ ptRev with frame a1 .
         end.

      end.

      if c-application-mode <> 'web' then
         pause before-hide.
      if ppform = "" or ppform = "b"

      then do:

         /* get picking order */
         {us/px/pxrun.i &PROC  = 'getFieldDefault' &PROGRAM = 'ppitxr.p'
            &HANDLE = ph_ppitxr
            &PARAM = "(input pt_part,
              input site,
              input ""pt_pk_ord"",
              output pickingOrder)"
            &NOAPPERROR = true
            &CATCHERROR = true}
         assign ptPickOrder = integer(pickingOrder).

         /* get picking order */
         {us/px/pxrun.i &PROC  = 'getFieldDefault' &PROGRAM = 'ppitxr.p'
            &HANDLE = ph_ppitxr
            &PARAM = "(input pt_part,
              input site,
              input ""pt_ascend"",
              output pickingAscDesc)"
            &NOAPPERROR = true
            &CATCHERROR = true}
         assign ptPickAscend = logical(pickingAscDesc = "yes").

         /* get item issue policy */
         {us/px/pxrun.i &PROC  = 'getFieldDefault' &PROGRAM = 'ppitxr.p'
            &HANDLE = ph_ppitxr
            &PARAM = "(input pt_part,
              input site,
              input ""pt_iss_pol"",
              output itemIssuePolicy)"
            &NOAPPERROR = true
            &CATCHERROR = true}

         /* GET ISSUE POLICY DISPLAY FLAG FROM lngd_det */
         {us/px/pxrun.i &PROC  ='convertNumericToAlpha'
            &PROGRAM = 'gplngxr.p'
            &HANDLE=ph_gplngxr
            &PARAM = "(input 'wo_mstr',
              input 'issuePolicy',
              input itemIssuePolicy,
              output issuePolicyDisp,
              output issuePolicyDispDesc)"
            &NOAPPERROR = true
            &CATCHERROR = true}

         /* get item pick policy */
         {us/px/pxrun.i &PROC  = 'getFieldDefault' &PROGRAM = 'ppitxr.p'
            &HANDLE = ph_ppitxr
            &PARAM = "(input pt_part,
              input site,
              input ""pt_pick_pol"",
              output itemPickPolicy)"
            &NOAPPERROR = true
            &CATCHERROR = true}

         /* GET ISSUE POLICY DISPLAY FLAG FROM lngd_det */
         {us/px/pxrun.i &PROC  ='convertNumericToAlpha'
            &PROGRAM = 'gplngxr.p'
            &HANDLE=ph_gplngxr
            &PARAM = "(input 'wo_mstr',
              input 'pickPolicy',
              input itemPickPolicy,
              output pickPolicyDisp,
              output pickPolicyDispDesc)"
            &NOAPPERROR = true
            &CATCHERROR = true}

         if ppform = "" then hide frame a1.

         display {us/pp/pppsmta3.i} with frame b1.

         for first si_mstr where si_domain = global_domain
                           and   si_site   = site
         no-lock: end.
         for first pti_det where pti_det.oid_pt_mstr = pt_mstr.oid_pt_mstr
                           and   pti_det.oid_si_mstr = si_mstr.oid_si_mstr
         no-lock:
            display
               pti_abc       @ pt_abc
               pti_cyc_int   @ pt_cyc_int
               pti_avg_int   @ pt_avg_int
               pti_loc       @ pt_loc
               pti_loc_type  @ pt_loc_type
               pti_shelflife @ pt_shelflife
               pti_critical  @ pt_critical
               pti_memo_type @ pt_memo_type
               pti_lot_ser   @ pt_lot_ser
               pti_auto_lot  @ pt_auto_lot
               pti_rctwo_status @ pt_rctwo_status
               pti_rctwo_active @ pt_rctwo_active
               pti_rctpo_status @ pt_rctpo_status
               pti_rctpo_active @ pt_rctpo_active
            with frame b1.
         end.

         display
            ptPickOrder @ pt_pk_ord
            ptPickAscend @ pt_ascend with frame b1.

         hide frame b1.

         for first comd_det  where comd_det.comd_domain = global_domain and
         comd_part = pt_part
         no-lock:
         end.
         if available comd_det then
            assign l_comm_code = comd_comm_code.
         else
            assign l_comm_code = "".

         display {us/pp/pppsmt10.i} with frame bb.

         if keyfunction(lastkey) = "end-error" then
            undo, next mainloop.
         hide frame bb.
         if (ppform = "b" and dev = "terminal") then yn = no.

      end. /* IF ppform = "" OR ppform = "b" */

      if ppform = "" or ppform = "c"

      then do:

         find ptp_det  where ptp_det.ptp_domain = global_domain and  ptp_part =
         in_part
            and ptp_site = in_site
         no-lock no-error.
         if available ptp_det then do:

            /* GET DEFAULT BTB TYPE FROM lngd_det */
            {us/gp/gplngn2a.i &file = ""emt""
               &field = ""btb-type""
               &code  = ptp_btb_type
               &mnemonic = btb-type
               &label = btb-type-desc}

            /* GET DEFAULT ATP ENFORCEMENT TYPE FROM lngd_det */
            {us/gp/gplngn2a.i &file = ""atp""
               &field = ""atp-enforcement""
               &code  = ptp_atp_enforcement
               &mnemonic = atp-enforcement
               &label = atp-enforce-desc}

            if ptp__qad02 = 1 then emt-auto = yes.
            {us/px/pxgetph.i pprevxr}
            ptpRev = {us/px/pxfunct.i &FUNCTION='getValidItemRevision'
               &PROGRAM='pprevxr.p'
               &HANDLE=ph_pprevxr
               &PARAM= "input ptp_part,
                 input ptp_site,
                 input today"}.

            {us/gp/gplngn2a.i &file = ""rep_mthd2""
                        &field = ""replenishment_method""
                        &code = ptp_replenishment_mthd
                        &mnemonic = replenishment_method
                        &label = replenishment_method_label}
            if ptp__qad02 = 1 then emt-auto = yes.

            assign
               schedType  = ptp_schedule_type
               ptavgperiod = ptp_avg_period.
            {us/px/pxrun.i &PROC  ='convertNumericToAlpha'
               &PROGRAM = 'gplngxr.p'
               &HANDLE=ph_gplngxr
               &PARAM = "(input 'MPS',
                 input  'mpsos_smoothing_rule',
                 input  ptp_smoothing_rule,
                 output smoothingRule,
                 output cdesc)"
               }

            {us/px/pxrun.i &PROC  ='convertNumericToAlpha'
               &PROGRAM = 'gplngxr.p'
               &HANDLE=ph_gplngxr
               &PARAM = "(input 'MPS',
                 input  'mpsos_period_type',
                 input  ptp_period_type,
                 output periodType,
                 output cdesc)"
               }

            display {us/pp/pppsmta4.i} with frame c1.
            if ptp_bom_code <> "" then
            find bom_mstr no-lock
                where bom_mstr.bom_domain = global_domain and  bom_parent =
                ptp_bom_code no-error.
            else
            find bom_mstr no-lock
                where bom_mstr.bom_domain = global_domain and  bom_parent =
                ptp_part no-error.
            display
               bom_batch when (available bom_mstr and bom_batch <> 0)
               @ ptp_batch
               1 when ( not available bom_mstr
               or (available bom_mstr and bom_batch = 0)) @ ptp_batch
            with frame c1.

            /* DISPLAY CONFIGURATION TYPE */
            /* GET MNEMONIC cfg AND cfglabel FROM LNGD_DET */
            assign
               cfg = ptp_cfg_type
               cfglabel = ""
               cfgcode = "".

            {us/gp/gplngn2a.i &file     = ""pt_mstr""
               &field    = ""pt_cfg_type""
               &code     = ptp_cfg_type
               &mnemonic = cfg
               &label    = cfglabel}

            display cfg with frame c1.

            hide frame c1.
            display {us/pp/ppptmtab.i} with frame c0.
            hide frame c0.
            display {us/pp/pppsmta5.i} with frame c2.

         end.
         else do:

            /* GET DEFAULT ATP ENFORCEMENT TYPE FROM lngd_det */
            {us/gp/gplngn2a.i &file = ""atp""
               &field = ""atp-enforcement""
               &code  = pt_atp_enforcement
               &mnemonic = atp-enforcement
               &label = atp-enforce-desc}

            /* GET DEFAULT BTB TYPE FROM lngd_det */
            {us/gp/gplngn2a.i &file = ""emt""
               &field = ""btb-type""
               &code  = pt_btb_type
               &mnemonic = btb-type
               &label = btb-type-desc}
            {us/px/pxgetph.i pprevxr}
            ptRev = {us/px/pxfunct.i &FUNCTION='getValidItemRevision'
               &PROGRAM='pprevxr.p'
               &HANDLE=ph_pprevxr
               &PARAM= "input pt_part,
                 input '',
                 input today"}.

            {us/gp/gplngn2a.i &file = ""rep_mthd2""
                        &field = ""replenishment_method""
                        &code = pt_replenishment_mthd
                        &mnemonic = replenishment_method
                        &label = replenishment_method_label}

            schedType = pt_schedule_type.
            {us/px/pxrun.i &PROC  ='convertNumericToAlpha'
               &PROGRAM = 'gplngxr.p'
               &HANDLE=ph_gplngxr
               &PARAM = "(input 'MPS',
                 input  'mpsos_smoothing_rule',
                 input  pt_smoothing_rule,
                 output smoothingRule,
                 output cdesc)"
               }

            {us/px/pxrun.i &PROC  ='convertNumericToAlpha'
               &PROGRAM = 'gplngxr.p'
               &HANDLE=ph_gplngxr
               &PARAM = "(input 'MPS',
                 input  'mpsos_period_type',
                 input  pt_period_type,
                 output periodType,
                 output cdesc)"
               }

            display {us/pp/ppptmta4.i} with frame c.
            display in_mrp @ pt_mrp with frame c.

            if pt_bom_code <> "" then
            find bom_mstr no-lock
                where bom_mstr.bom_domain = global_domain and  bom_parent =
                pt_bom_code no-error.
            else
            find bom_mstr no-lock
                where bom_mstr.bom_domain = global_domain and  bom_parent =
                pt_part no-error.
            display
               bom_batch when (available bom_mstr and bom_batch <> 0)
               @ pt_batch
               1 when ( not available bom_mstr
               or (available bom_mstr and bom_batch = 0)) @ pt_batch
            with frame c.

            /* DISPLAY CONFIGURATION TYPE */
            assign
               cfg = pt_cfg_type
               cfglabel = ""
               cfgcode = "".
            /* GET MNEMONIC cfg AND cfglabel FROM LNGD_DET */
            {us/gp/gplngn2a.i &file     = ""pt_mstr""
               &field    = ""pt_cfg_type""
               &code     = pt_cfg_type
               &mnemonic = cfg
               &label    = cfglabel}

            display cfg with frame c.

            hide frame c.
            display {us/pp/ppptmtab.i} with frame c0.
            display {us/pp/ppptmta6.i} with frame c3.

         end.

         if keyfunction(lastkey) = "end-error" then
            undo, next mainloop.
      end.

      if ppform = "" or ppform = "d"

      then do:
         if dev = "terminal" then yn = no.

         if ppform = ""
         then do:
            hide frame c.
            hide frame c0.
            hide frame c1.
            hide frame c2.
            hide frame c3.
         end.

         /* SEARCH THE FISCAL CLASS DESCRIPTION */
         c_fiscal_desc = "".
         {us/gp/gprunp.i "gpcodxr" "p" "getGeneralizedCodeDescription"
            "(input  ""pt_fiscal_class"",
              input  pt_fiscal_class,
              output c_fiscal_desc)"}

         display {us/pp/ppptmta5.i} with frame d1.

         find first icc_ctrl  where icc_ctrl.icc_domain = global_domain no-lock.

         if in_gl_set = "" then
         find sct_det  where sct_det.sct_domain = global_domain and  sct_sim =
         icc_gl_set
            and sct_part = in_part and sct_site = in_gl_cost_site
         no-lock no-error.
         else
         find sct_det  where sct_det.sct_domain = global_domain and  sct_sim =
         in_gl_set
            and sct_part = in_part and sct_site = in_gl_cost_site
         no-lock no-error.

         if available sct_det then do:
            assign csset = sct_det.sct_sim.

            frtitle = getFrameTitle("GL_COST_DATA",18).
            if in_site <> "" then
               frtitle = frtitle + "(" +  getTermLabel("GL_COST_SOURCE_SITE",24)
               + ": " +
               in_gl_cost_site + " / " + getTermLabel("SET",6)  + ": " +
               csset + ") ".

            {us/bbi/gprun.i ""ppptiqd.p""
               "(input recid(sct_det), input frtitle)"}
         end.

         put skip.
         clear frame d all.
         hide frame d0.
         hide frame d.

         if keyfunction(lastkey) = "end-error" then
            undo, next mainloop.

         if in_cur_set = "" then
         find sct_det  where sct_det.sct_domain = global_domain and  sct_sim =
         icc_cur_set
            and sct_part = in_part and sct_site = in_site
         no-lock no-error.
         else
         find sct_det  where sct_det.sct_domain = global_domain and  sct_sim =
         in_cur_set
            and sct_part = in_part and sct_site = in_site
         no-lock no-error.

         if available sct_det then do:
            assign csset = sct_det.sct_sim.

            frtitle = getFrameTitle("CURRENT_COST_DATA",24).
            if in_site <> "" then
               frtitle = frtitle + "(" +  getTermLabel("GL_COST_SOURCE_SITE",24)
               + ": " +
               in_site + " / " + getTermLabel("SET",6)  + ": " +
               csset + ") ".

            {us/bbi/gprun.i ""ppptiqd.p""
               "(input recid(sct_det), input frtitle)"}
         end.

         clear frame d all.
         hide frame d0.
         hide frame d1.
         hide frame d.
      end.
      if keyfunction(lastkey) = "end-error" then undo, next mainloop.
      if dev = "terminal" and yn then
         if c-application-mode <> 'web' then
         pause.
      put skip.

   end.  /*for each in_mstr*/

   {us/bbi/mfreset.i}
   {us/bbi/pxmsg.i &MSGNUM=8 &ERRORLEVEL=1}
end.

{us/wb/wbrp04.i &frame-spec = a}

